package com.esrichina.list;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author :   luojie
 * date:     2019/8/11 19:33
 * description:
 */
public class TestFilterOrder {

    public static void main(String[] args) {
        List<Order> orders = new ArrayList<>();
        orders.add(new Order("20190811", "test"));//6
        orders.add(new Order("20190810", "test"));
        orders.add(new Order("20190809", "test"));
        orders.add(new Order("20190711", "test"));
        orders.add(new Order("20190611", "test"));
        orders.add(new Order("20190511", "test"));
        orders.add(new Order("20180811", "test"));//4
        orders.add(new Order("20180911", "test"));
        orders.add(new Order("20180211", "test"));
        orders.add(new Order("20180411", "test"));
        orders.add(new Order("20170811", "test"));//5
        orders.add(new Order("20170810", "test"));
        orders.add(new Order("20170911", "test"));
        orders.add(new Order("20170211", "test"));
        orders.add(new Order("20170611", "test"));
        orders.add(new Order("20160811", "test"));//5
        orders.add(new Order("20160810", "test"));
        orders.add(new Order("20160911", "test"));
        orders.add(new Order("20160211", "test"));
        orders.add(new Order("20160611", "test"));
        Map<Integer, Stat> map = new HashMap<>();
        List<Integer> list = new ArrayList<>();
        List<Stat> stats = new ArrayList<>();
        List<Order> a = orders.stream().filter(order -> order.getOrderNo().indexOf("2019") > -1).collect(Collectors.toList());
        stats.add(new Stat("2019", a.size()));
        List<Order> b = orders.stream().filter(order -> order.getOrderNo().indexOf("2018") > -1).collect(Collectors.toList());
        stats.add(new Stat("2018", b.size()));
        List<Order> c = orders.stream().filter(order -> order.getOrderNo().indexOf("2017") > -1).collect(Collectors.toList());
        stats.add( new Stat("2017", c.size()));
        List<Order> d = orders.stream().filter(order -> order.getOrderNo().indexOf("2016") > -1).collect(Collectors.toList());
        stats.add( new Stat("2016", d.size()));
        System.out.println(a.size() + ", " + b.size() + ", " + c.size());
        Collections.sort(stats,Collections.reverseOrder());
        System.out.println(stats);
    }
}
